import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import com.lijie.ljblog.enums.ChessColorEnum;
import com.lijie.ljblog.util.FileUtils;
import com.lijie.ljblog.util.MusicUtils;
import org.junit.Test;
import org.springframework.http.HttpHeaders;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
import java.util.concurrent.*;


/**
 * @Title: ljblog_springboot
 * @Description: ()
 * @Author:lijie
 * @Version:1.1.0
 * @since 2022/1/10
 */

public class test2 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
//        Callable<String> stringCallable = new Callable<String>(){
//
//            @Override
//            public String call() throws Exception {
//                int i=1;
//                for(;i<=10;++i){
//                    System.out.println(i);
//                }
//                return "执行完成,打印次数："+i;
//            }
//        };
//        ExecutorService ex=Executors.newFixedThreadPool(3);
//        Future<String> submit = ex.submit(stringCallable);
//        String s = submit.get();
//        System.out.println(s);

//        String url ="lippi-space-sh.oss-cn-shanghai.aliyuncs.com/yundisk0/iAEIAqRmaWxlA6h5dW5kaXNrMATOIT9uoAXNEvMGzZRMB85mnv7pCM0CmA.file?Expires=1721696894&OSSAccessKeyId=LTAIjmWpzHta71rc&Signature=MhaDeiFENs5U%2Fo0I7YTEPAiTXRI%3D";
//        byte[] bytes = HttpUtil.downloadBytes("");
//        byte[] bytes = HttpUtil.downloadBytes("http://lippi-space-sh.oss-cn-shanghai.aliyuncs.com/yundisk0/iAEIAqRmaWxlA6h5dW5kaXNrMATOIT9uoAXNEvMGzZRMB85mnv7pCM0CmA.file?Expires=1721696894&OSSAccessKeyId=LTAIjmWpzHta71rc&Signature=MhaDeiFENs5U%2Fo0I7YTEPAiTXRI%3D");
//        System.out.println(bytes);

        String url = "江宁经济开江宁经济开江宁经济开江宁经济开江宁经济开江宁经济开江宁经济开江宁经济开江宁经济开江宁经济开江宁经济开江宁经济开江宁经济开江宁经济开江宁经济开江宁经济开江宁经济开江宁经济开";

        System.out.println(StrUtil.length(url));

    }
    //选择排序
    public int[] sort(int[] param){
        for(int i=0;i<param.length;i++){
            int min=i;
            for(int j=i+1;j<param.length;j++){
                if(param[min]>param[j]){
                    min=j;
                }
            }
            //交换最小的
            int temp=param[i];
            param[i]=param[min];
            param[min]=temp;
        }
        return param;
    }
//    //快速排序
//    public int[] quickSort(int[] x,int left,int right){
//
//    }
    public void InsertSort(int[] array){
        int index=0;//判断的下标
        for(int i=1;i<array.length;i++){
            index=i-1;
            int temp=array[i];
            while(index>=0&&array[index]>temp){
                array[index+1]=array[index];
                index--;
            }
            array[index+1]=temp;
        }
    }
    public void QuickSort(int[] array,int low,int high){
        if(low>high){
            return ;
        }
        int i,j;//i:哨兵，从左往右，找比基准数大的数；J：哨兵，从右往左找比基准数小的
        i=low;j=high;
        int temp=array[low];//基准数
        while(i<j){
            //先从右往左查询比基准数小的数
            while(array[j]>=temp&&i<j){
                j--;
            }
            //从左往右查询比基准数大的数
            while(array[i]<=temp&&i<j){
                i++;
            }
            //满足条件则交换 i和J
            if(i<j){
                int swap=array[j];
                array[j]=array[i];
                array[i]=swap;
            }
        }
        array[low]=array[i];
        array[i]=temp;
        //递归调用，基准数左边 和基准数右边的数
        QuickSort(array,low,i-1);
        QuickSort(array,i+1,high);
    }


    @Test
    public void run(){
//        test2 test2 = new test2();
//        int[] x={-111,90,61,71};
//        QuickSort(x,0,x.length-1);
//        System.out.println(1);
        ArrayList<String> strings = new ArrayList<>();
        strings.add("1");
        strings.add("f");
        strings.add("a");
        strings.add("d");
        System.out.println(strings);
    }

    @Test
    public void stringDo(){
        String x="http://localhost:1414/11jkfjsdklfjsfhfldhflfh/adasdsjdlkasdj/asdadsa0";
        String substring = x.substring("http://localhost:1414".length());
        System.out.println(substring);
    }
    @Test
    public void go(){
        ChessColorEnum x = ChessColorEnum.valueOf(ChessColorEnum.class,"CHESS_POINT_WHITE");
        System.out.println(x);
    }
    @Test
    public void go1(){

        System.out.println(DateUtil.today());
    }
    @Test
    public void music() throws Exception {
        File file = new File("C:\\Users\\Blackjie\\Music\\Music\\光年之外.mp3");
        byte[] mp3Image = MusicUtils.getMp3Image(file);
        String musicImageName= UUID.randomUUID().toString()+".jpg";
        FileUtils.saveFile(file.getParentFile().getPath(),musicImageName,mp3Image);
//        musicFilePath+musicImageName
//        musicInfo.setCover(musicFilePath+musicImageName);
    }
    @Test
    public void music1() throws Exception {
        String s = new String();
        s="C:\\Users\\Blackjie\\Music\\Music\\光年之外.mp3";
        System.out.println(s);
        System.out.println(s.substring(0, s.lastIndexOf("\\")));
    }

}
